/**
 * @(#) EpuckLightActuator.java
 */

package pcsr.drivers.epuckDriver;

import pcsr.drivers.epuckDriver.command.IePuckUartProtocol.LedNumber;

class EpuckLightActuator implements IEpuckActuator
{
	private EPuck epuckrobot;
	private LedNumber mynumber;
	boolean ledOn;
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String GetID() {
		return mynumber.name();
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public EpuckActuatorMode GetMode() {
		return EpuckActuatorMode.SETVALUEONLY;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public EpuckActuatorType GetType() {
		return EpuckActuatorType.LIGHT;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public short GetValue() {
		return (short) (ledOn ? 1 : 0);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void SetValue(short newValue) {
		ledOn = newValue > 0;
		epuckrobot.SendActuatorUpdateCommand(this);		
	}

	/**
	 * @return the  led number
	 */
	LedNumber GetLedNumber() {
		return mynumber;
	}

	public EpuckLightActuator(EPuck owner, LedNumber led) {
		epuckrobot = owner;
		mynumber = led;
	}
	
}
